<?php

namespace App\Models;

use App\Api\Filters\BookCollectionFilter;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;

class BookCollection extends Model
{
    use SoftDeletes;

    protected $guarded = [];

    public function user(){

        return $this->belongsTo(User::class);
    }

    // 对书籍书单进行过滤
    public function scopeFilter($query, BookCollectionFilter $filters)
    {

        return $filters->apply($query);
    }

    public function bookList(){

        return $this->hasMany(BookList::class);
    }

}
